<template>
	<z-paging ref="paging" v-model="list" @query="getList" loading-more-default-text="我也是有底线的哦">
		<view class="mainBg h100">
			<navbar title="我的订单" />
			<view class="tabs">
				<view class="tab" :class="status == 'all' ? `active` : ``" @click="changeStatus(`all`)">
					全部
				</view>
				<!-- <view class="tab" :class="status == 'pending' ? `active` : ``" @click="changeStatus(`pending`)">
					待支付
				</view> -->
				<view class="tab" :class="status == 'success' ? `active` : ``" @click="changeStatus(`success`)">
					已完成
				</view>
				<view class="tab" :class="status == 'refund' ? `active` : ``" @click="changeStatus(`refund`)">
					已退款
				</view>
		<!-- 		<view class="tab" :class="status == 'closed' ? `active` : ``"@click="changeStatus(`closed`)">
					已关闭
				</view> -->
			</view>
			<view class="list">
				<view class="col" v-for="item,index in list" :key="item.id">
					<item :item="item" :scene="scene" />
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script>
	import item from "./item.vue"
	export default {
		components: {
			item
		},
		data() {
			return {
				list: [],
				status:'all',
				pageNo:1,
				pageSize:10,
				scene:'order',
			}
		},
		methods: {
			getList() {
				this.$get(`/order/orderList`, {
					pageNum: this.pageNo,
					pageSize:this.pageSize,
					status:this.status,
				}).then(res => {
					//请勿在网络请求回调中给dataList赋值！！只需要调用complete就可以了
					this.$refs.paging.complete(res.data.rows);
				})
			},
			changeStatus(status){
				this.status = status
				this.$refs.paging.reload() 
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #35CBAD;
	}

	.tabs {
		display: flex;
		background-color: #fff;

		.tab {
			flex: 1;
			font-size: 28rpx;
			text-align: center;
			line-height: 100rpx;
			position: relative;
		}

		.active {
			font-weight: bold;
			color: $assist-color2;

			&:before {
				content: '';
				width: 80rpx;
				height: 6rpx;
				position: absolute;
				left: 50%;
				bottom: 0%;
				transform: translateX(-50%);
				background-color: $assist-color2;
			}
		}
	}

	.list {
		padding: 10rpx 0;

		.col {
			padding: 10rpx 0;
		}
	}
</style>